import type { CsdnArticleVO, CsdnArticleForm, CsdnArticleQuery } from './model';

import type { ID, IDS } from '#/api/common';
import type { PageResult } from '#/api/common';

import { commonExport } from '#/api/helper';
import { requestClient } from '#/api/request';

/**
* 查询CSDN文章发布列表
* @param params
* @returns CSDN文章发布列表
*/
export function csdnArticleList(params?: CsdnArticleQuery) {
  return requestClient.get<PageResult<CsdnArticleVO>>('/csdn/csdnArticle/list', { params });
}

/**
 * 导出CSDN文章发布列表
 * @param params
 * @returns CSDN文章发布列表
 */
export function csdnArticleExport(params?: CsdnArticleQuery) {
  return commonExport('/csdn/csdnArticle/export', params ?? {});
}

/**
 * 查询CSDN文章发布详情
 * @param id id
 * @returns CSDN文章发布详情
 */
export function csdnArticleInfo(id: ID) {
  return requestClient.get<CsdnArticleVO>(`/csdn/csdnArticle/${id}`);
}

/**
 * 新增CSDN文章发布
 * @param data
 * @returns void
 */
export function csdnArticleAdd(data: CsdnArticleForm) {
  return requestClient.postWithMsg<void>('/csdn/csdnArticle', data);
}

/**
 * 更新CSDN文章发布
 * @param data
 * @returns void
 */
export function csdnArticleUpdate(data: CsdnArticleForm) {
  return requestClient.putWithMsg<void>('/csdn/csdnArticle', data);
}

/**
 * 删除CSDN文章发布
 * @param id id
 * @returns void
 */
export function csdnArticleRemove(id: ID | IDS) {
  return requestClient.deleteWithMsg<void>(`/csdn/csdnArticle/${id}`);
}
